#!coding=utf-8
from __future__ import unicode_literals
from datetime import datetime

from django.db import models
from Users.models import UserProfile

# Create your models here.


class SaltCommand(models.Model):
    name = models.CharField(verbose_name=u'名称', max_length=100)
    context = models.TextField(verbose_name=u'脚本', null=True)
    type = models.SmallIntegerField(verbose_name=u'命令类型', choices=((0, u'远程命令'), (1, u'shell脚本'), (2, u'SaltSate'), (3, u'文件传输'), (4, u'Salt模块')))
    description = models.TextField(verbose_name=u'说明', default='')
    cmd = models.CharField(verbose_name=u'命令', max_length=100, default='')
    args = models.CharField(verbose_name=u'参数', max_length=100, null=True)
    path = models.TextField(verbose_name=u'文件路径', default='')
    add_time = models.DateTimeField(verbose_name=u'添加时间', default=datetime.now)


class SaltLog(models.Model):
    exec_time = models.DateTimeField(verbose_name=u'时间', default=datetime.now)
    cmd = models.ForeignKey('SaltCommand')
    minions = models.TextField(default='')
    user = models.ForeignKey(UserProfile)
    result = models.TextField(default='')